package com.atguigu.userprofile.mapper;

import com.atguigu.userprofile.bean.UserGroup;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import javax.ws.rs.DELETE;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2021-05-04
 */


@Mapper
@DS("mysql")
public interface UserGroupMapper extends BaseMapper<UserGroup> {

    @Insert(" ${insertSQL}")   //# 半自动  会自动根据参数 来判断是否加单引  $ 原封不动
    @DS("clickhouse")
    public void   insertUserGroupCK(String insertSQL);


    @Select(" select  arrayJoin( bitmapToArray(us) ) from user_group where user_group_id =#{userGroupId}")
    @DS("clickhouse")
    public List<String>  selectUserGroupFromCK(String  userGroupId);

    @Select("select bitmapCardinality(  ${bitmapAndSQL} )")
    @DS("clickhouse")
    public  Long  selectUserGroupNum(String bitmapAndSQL);

    @Select("select  arrayJoin( bitmapToArray( ${bitmapAndSQL}) ) ")
    @DS("clickhouse")
    public List<String>  selectBitmapAndFromCK(String bitmapAndSQL);


    @Select("alter table user_group delete where user_group_id=#{userGroupId}")
    @DS("clickhouse")
    public void deleteUserGroup(String userGroupId);
}
